package com.hc.sss.lcx.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hc.sss.common.ResultMap;
import com.hc.sss.pojo.Address;
import com.hc.sss.pojo.User;
import com.hc.sss.service.AddressService;
/**
 * 地址表
 * @author lcx
 *2021年4月9日15:16:11
 */
@RestController
@RequestMapping("/address")
public class AddressController {
	@Autowired 
	private AddressService addressService;
	
	@RequestMapping("/list")
	public ResultMap<Address> findListAddress(Address address,HttpServletRequest request){
		User user=(User) request.getSession().getAttribute("user");
		Map<String,Object> param=new HashMap();
		param.put("addrUserId", user.getUserId());
		param.put("address", address);
		ResultMap<Address> resultmap=addressService.findListAddress(param);
		return resultmap;
	}
	
	@RequestMapping("/add")
	public int addAddress(Address address,HttpServletRequest request){
		User user=(User) request.getSession().getAttribute("user");
		address.setAddrUserId(user.getUserId());
		
		return addressService.addAddres(address);
	}
	
	@RequestMapping("/del")
	public int deleteAddress(String addrId){
		return addressService.deleteByPrimaryKey(addrId);
	}
	
	@RequestMapping("/update")
	public int UpdateAddress(Address address){
		
		return addressService.updateByPrimaryKeySelective(address);
	}
	
		
}
